package com.west_traveler.viewpager_adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.west_traveler.download_page_fragment.DownloadAlbumFragment;
import com.west_traveler.download_page_fragment.DownloadVoiceFragment;
import com.west_traveler.download_page_fragment.DownloadingFragment;

/**
 * Description: xxx
 * Date:2016年12月05日16:09
 *
 * @author: 刘悦.
 */

public class DownloadPageViewPagerAdapter extends FragmentStatePagerAdapter {

    private String[] tabNames;

    public DownloadPageViewPagerAdapter(FragmentManager fm, String[] tabNames) {
        super(fm);
        this.tabNames = tabNames;
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return DownloadAlbumFragment.getInstance();
            case 1:
                return DownloadVoiceFragment.getInstance();
            case 2:
                return DownloadingFragment.getInstance();
            default:
                return DownloadAlbumFragment.getInstance();
        }
    }

    @Override
    public int getCount() {
        return tabNames.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabNames[position];

    }
}
